package com.example.shixunandjavagotoyangchen.BoosYang.Day002;

import android.util.Log;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;

import com.example.modelviewpresenter.View.BasterFragment;
import com.example.shixunandjavagotoyangchen.BoosYang.Day002.Day002_1107.PackageAdpter;
import com.example.shixunandjavagotoyangchen.BoosYang.Day002.Day002_1107.PackageBean;
import com.example.shixunandjavagotoyangchen.BoosYang.Day002.Day002_1107.PackageContion;
import com.example.shixunandjavagotoyangchen.BoosYang.Day002.Day002_1107.PackageModel;
import com.example.shixunandjavagotoyangchen.BoosYang.Day002.Day002_1107.PackagePresenter;
import com.example.shixunandjavagotoyangchen.BoosYang.Day002.Day002_1108.BeautymakeupAdpter;
import com.example.shixunandjavagotoyangchen.BoosYang.Day002.Day002_1108.BeautymakeupBean;
import com.example.shixunandjavagotoyangchen.BoosYang.Day002.Day002_1108.BeautymakeupContion;
import com.example.shixunandjavagotoyangchen.BoosYang.Day002.Day002_1108.BeautymakeupModel;
import com.example.shixunandjavagotoyangchen.BoosYang.Day002.Day002_1108.BeautymakeupPresenter;
import com.example.shixunandjavagotoyangchen.R;
import com.scwang.smart.refresh.layout.SmartRefreshLayout;
import com.scwang.smart.refresh.layout.api.RefreshLayout;
import com.scwang.smart.refresh.layout.listener.OnRefreshLoadMoreListener;

import java.util.List;


public class BlankFragmentDay002_1107 extends BasterFragment   implements OnRefreshLoadMoreListener, PackageContion.vier {


    public static SmartRefreshLayout PackageSmartRefreshLayout;
    private RecyclerView PackageRecyclerView;
    public boolean issdd= true;
    public PackageAdpter adpter;
    public PackagePresenter presenter;

    @Override
    public int BandLayout() {
        return R.layout.fragment_blank_fragment_day002_1107;
    }

    @Override
    public void initView() {

        PackageSmartRefreshLayout = (SmartRefreshLayout) findViewById(R.id.Package_SmartRefreshLayout);
        PackageRecyclerView = (RecyclerView) findViewById(R.id.Package_RecyclerView);
        PackageRecyclerView.setLayoutManager(new StaggeredGridLayoutManager(3,StaggeredGridLayoutManager.VERTICAL));
        PackageSmartRefreshLayout.setOnRefreshLoadMoreListener(this);
        presenter = new PackagePresenter(this,new PackageModel());
        presenter.packaing("Home_zidingyi.php");

    }

    @Override
    public void initDate() {

    }


    @Override
    public void getvier(List<PackageBean.ShujuBean> dataBeans) {
        PackageSmartRefreshLayout.finishLoadMore();
        PackageSmartRefreshLayout.finishRefresh();
        if (adpter==null){
            adpter = new PackageAdpter(dataBeans);
            PackageRecyclerView.setAdapter(adpter);
        }else {
            if (issdd){
                adpter.getData().clear();
            }
            adpter.getData().addAll(dataBeans);
            adpter.notifyDataSetChanged();
        }
    }

    @Override
    public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
        issdd =false;
        refreshLayout.finishLoadMore();
        refreshLayout.finishRefresh();
    }

    @Override
    public void onRefresh(@NonNull RefreshLayout refreshLayout) {
        if (issdd){
            Log.i("aaa","la1");
        }
        refreshLayout.finishLoadMore();
        refreshLayout.finishRefresh();
    }


}
